package com.yunkeji.admin.controller.sys;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.yunkeji.common.annotation.Log;
import com.yunkeji.common.annotation.RepeatSubmit;
import com.yunkeji.common.core.controller.BaseController;
import com.yunkeji.common.core.domain.PageQuery;
import com.yunkeji.common.core.domain.R;
import com.yunkeji.common.core.page.TableDataInfo;
import com.yunkeji.common.enums.BusinessType;
import com.yunkeji.dao.domain.SysMsgLog;
import com.yunkeji.dao.vo.SysMsgLogVo;
import com.yunkeji.system.service.ISysMsgLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 后台系统消息发送记录
 *
 * @author 雷擎宇
 * @date 2024-11-15
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/sysMsgLog")
public class SysMsgLogController extends BaseController {

    private final ISysMsgLogService sysMsgLogService;

    /**
     * 查询后台系统消息发送记录列表
     */
    @SaCheckPermission("system:sysMsgLog:list")
    @GetMapping("/list")
    public TableDataInfo<SysMsgLogVo> list(SysMsgLog bo, PageQuery pageQuery) {
        return sysMsgLogService.queryPageList(bo, pageQuery);
    }

    /**
     * 新增后台系统消息发送记录
     */
    @SaCheckPermission("system:sysMsgLog:add")
    @Log(title = "新增后台系统消息发送记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Valid @RequestBody SysMsgLog bo) {
        sysMsgLogService.insert(bo);
        return R.ok();
    }

}
